from copy import copy
import pygame
import UAI

def drawCross((x, y), color=(255,0,0)):
    pygame.draw.line(UAI.window.image, color, (x,y-3),(x,y+3))
    pygame.draw.line(UAI.window.image, color, (x-3,y),(x+3,y))

def drawPos(pos, color=(255,0,0)):
    rect = pygame.Rect(0,0,2,2)
    rect.center = pos
    drawRect(rect, color)
  
def drawRect(rect, color=(255,0,0)):
    pygame.draw.rect(UAI.window.image, color, rect)
    
def drawLine(p1, p2, color=(255,0,0), width=1):
    pygame.draw.line(UAI.window.image, color, p1, p2, width)

def drawPath(node, color=(255,0,0)):
    while node.parent:
        drawLine(node.parent.pos, node.pos, color, 4)
        node = node.parent

def OSD(str):
    rect = copy(UAI.window.rect)
    rect.move_ip(5,5)
    text = UAI.font16.render(str, 1, UAI.colors.OSDTEXT_SHADOW)
    UAI.screen.blit(text, rect)
    rect.move_ip(-1,-1)
    text = UAI.font16.render(str, 1, UAI.colors.OSDTEXT)
    UAI.screen.blit(text, rect)
    
def log(text, newline = True):
    text = str(text)
    if newline:
        print text
    else:
        print text,
